using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Data.Models.Mapping
{
    public class CostDetailMap : EntityTypeConfiguration<CostDetail>
    {
        public CostDetailMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            // Table & Column Mappings
            this.ToTable("CostDetail");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.OrderProcessID).HasColumnName("OrderProcessID");
            this.Property(t => t.DesignDetailID).HasColumnName("DesignDetailID");
            this.Property(t => t.MaterialCost).HasColumnName("MaterialCost");
            this.Property(t => t.LabourCost).HasColumnName("LabourCost");
            this.Property(t => t.ToolCost).HasColumnName("ToolCost");
            this.Property(t => t.OtherCost).HasColumnName("OtherCost");
            this.Property(t => t.TotalCost).HasColumnName("TotalCost");

            // Relationships
            this.HasOptional(t => t.DesignDetail)
                .WithMany(t => t.CostDetails)
                .HasForeignKey(d => d.DesignDetailID);
            this.HasOptional(t => t.OrderProcess)
                .WithMany(t => t.CostDetails)
                .HasForeignKey(d => d.OrderProcessID);

        }
    }
}
